home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
clean
/
sun3.lha
/
Sun3
/
seqdemos
/
revtwice.icl
< prev
next >
Wrap
Text File
|
1992-08-07
|
774b
|
34 lines
MODULE revtwice;
<<
Reversing a list a number of times using Twice.
A list containing 25 integers is reversed 65536 times by means
of four applications of the higher order function Twice.
Set the size of the A and B stack to at least 2m.
For less garbage collection try a bigger heap (e.g. 4m).
>>
IMPORT deltaM ,deltaI;
RULE
:: Revv [INT] -> [INT];
Revv l -> Rev l [];
:: Rev [INT] [INT] -> [INT];
Rev [x|r] list -> Rev r [x | list];
Rev [] list -> list;
:: FromTo INT INT -> [INT];
FromTo a b -> [a] , IF = a b
-> [a | FromTo (++ a) b];
:: Twice (=> x x) x -> x;
Twice f x -> f (f x);
:: Start -> [INT];
Start -> Twice Twice Twice Twice Revv (FromTo 1 25);